﻿#region Header

/*
    This file is part of nDoctor Light

    NDoctor is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    NDoctor is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with NDoctor.  If not, see <http://www.gnu.org/licenses/>.
*/

#endregion Header

namespace Probel.Ldoc.Services.Services
{
    public class SearchCriterion
    {
        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="Criterion"/> class.
        /// </summary>
        /// <param name="criterion">The criterion.</param>
        /// <param name="firstName">if set to <c>true</c> search in the first names.</param>
        /// <param name="lastName">if set to <c>true</c> search in the last names.</param>
        /// <param name="startWith">if set to <c>true</c> only select when start with criterion. Otherwise, search if names contain criterion</param>
        public SearchCriterion(string criterion, bool firstName, bool lastName, bool startWith = false)
        {
            this.Criterion = criterion.ToLower();
            this.IncludeFirstName = firstName;
            this.IncludeLastName = lastName;
            this.StartWith = startWith;
        }

        #endregion Constructors

        #region Properties

        public static SearchCriterion Joker
        {
            get { return new SearchCriterion("*", false, false); }
        }

        public string Criterion
        {
            get;
            private set;
        }

        public bool IncludeAll
        {
            get { return this.Criterion == "*"; }
        }

        public bool IncludeFirstName
        {
            get;
            private set;
        }

        public bool IncludeLastName
        {
            get;
            private set;
        }

        public bool StartWith
        {
            get; private set;
        }

        #endregion Properties
    }
}